import javax.swing.text.html.HTMLDocument;
import java.util.ArrayList;
import java.util.Iterator;

public class task5_01 {
    public static void main(String[] args) {
        //Arraylist
        ArrayList list=new ArrayList();
        //add()cun  get()qu
        list.add("hello");
        list.add("java");
        System.out.println("集合的长度"+list.size());
        System.out.println("集合的第一个元素是"+list.get(0));
ArrayList list1=new ArrayList();
Student s1=new Student("asd",15);
Student s2=new Student("sadw",23);
   list1.add(s1);
   list1.add(s2) ;
        System.out.println("集合的长度"+list1.size());
        System.out.println("集合的第一个元素是"+list1.get(0));

  for(int i=0;i<list1.size();i++){
      System.out.println(list1.get(i));

  }
        for (Object obj:list1) {
            System.out.println("2"+obj);
        }//1.获取迭代器的对象
        Iterator iterator=list1.iterator();
    //2.迭代器接口中有2个方法：hasNext()是否存在下一个元素

    while(iterator.hasNext()){
        System.out.println(iterator.hasNext());
    }}
}
